//
//
//  @ Project : AgriMarketSystem
//  @ Date : 18/10/2013
//  @ Author : NTT
//
//
using System.Collections.Generic;
using System.Linq;
namespace AgriMarketService
{
    public class TypeOfArticle
    {
        private int typeId;

        public int TypeId
        {
            get { return typeId; }
            set { typeId = value; }
        }
        private string typeName;

        public string TypeName
        {
            get { return typeName; }
            set { typeName = value; }
        }
        public TypeOfArticle(int typeId,string typeName)
        {
            this.typeId = typeId;
            this.typeName = typeName;
        }
        public TypeOfArticle()
        { 
        }

        public static List<TypeOfArticle> GetAllTypes()
        {
            AgriMarketDataClassesDataContext db = new AgriMarketDataClassesDataContext();
            List<TypeOfArticle> allTypes = (from tempType in db.Tbl_TypeOfArticles
                                            select new TypeOfArticle() { TypeId=tempType.TypeId,TypeName=tempType.Type}).ToList();
            return allTypes;
        }
        public static TypeOfArticle GetTypeById(int typeId)
        {
            AgriMarketDataClassesDataContext db = new AgriMarketDataClassesDataContext();
            TypeOfArticle type = (from tempType in db.Tbl_TypeOfArticles
                                  where tempType.TypeId == typeId 
                                  select new TypeOfArticle() { TypeId = tempType.TypeId, TypeName = tempType.Type }).FirstOrDefault();
            return type;
        }
    }
}